package com.sali.entity;

import java.util.concurrent.atomic.AtomicLong;

// 存放各个类型的采集指标
public class StatisticalIndicator {

    // 输入总数记录数
    private AtomicLong inputCountAtomic = new AtomicLong(0);

    // 过滤的记录数
    private AtomicLong filterCountAtomic = new AtomicLong(0);

    // 异常记录数
    private AtomicLong errorCountAtomic = new AtomicLong(0);

    // 输出总条数
    private AtomicLong outputCountAtomic = new AtomicLong(0);

    // 上次记录的输入总数
    private AtomicLong lastInputTotal = new AtomicLong(0);

    // 上次记录的输出总数
    private AtomicLong lastOutputTotal = new AtomicLong(0);

    // 上次记录的异常总数
    private AtomicLong lastErrorTotal = new AtomicLong(0);

    // 上次记录的过滤总数
    private AtomicLong lastFilterTotal = new AtomicLong(0);


    public StatisticalIndicator deepClone() {
        StatisticalIndicator dst = new StatisticalIndicator();
        dst.setInputCount(this.getInputCount());
        dst.setOutputCount(this.getOutputCount());
        dst.setFilterCount(this.getFilterCount());
        dst.setErrorCount(this.getErrorCount());

        dst.setLastInputTotal(this.getLastInputTotal());
        dst.setLastOutputTotal(this.getLastOutputTotal());
        dst.setLastFilterTotal(this.getLastFilterTotal());
        dst.setLastErrorTotal(this.getLastErrorTotal());
        return dst;
    }

    public void updateLastRecord() {
        this.lastInputTotal.set(this.inputCountAtomic.get());
        this.lastOutputTotal.set(this.outputCountAtomic.get());
        this.lastErrorTotal.set(this.errorCountAtomic.get());
        this.lastFilterTotal.set(this.filterCountAtomic.get());
    }

    public void filterCountInc() {
        this.filterCountAtomic.getAndIncrement();
    }


    public void errorCountInc() {
        this.errorCountAtomic.getAndIncrement();
    }


    public void inputInc() {
        this.inputCountAtomic.getAndIncrement();
    }

    public void outputInc() {
        this.outputCountAtomic.getAndIncrement();
    }

    public void setInputCount(AtomicLong inputCount) {
        this.inputCountAtomic = inputCount;
    }

    public void setFilterCount(AtomicLong filterCount) {
        this.filterCountAtomic = filterCount;
    }

    public void setErrorCount(AtomicLong errorCount) {
        this.errorCountAtomic = errorCount;
    }

    public void setOutputCount(AtomicLong outputCount) {
        this.outputCountAtomic = outputCount;
    }

    public void setLastInputTotal(AtomicLong lastInputTotal) {
        this.lastInputTotal = lastInputTotal;
    }

    public void setLastOutputTotal(AtomicLong lastOutputTotal) {
        this.lastOutputTotal = lastOutputTotal;
    }

    public void setLastErrorTotal(AtomicLong lastErrorTotal) {
        this.lastErrorTotal = lastErrorTotal;
    }

    public void setLastFilterTotal(AtomicLong lastFilterTotal) {
        this.lastFilterTotal = lastFilterTotal;
    }

    public AtomicLong getLastInputTotal() {
        return lastInputTotal;
    }

    public AtomicLong getLastOutputTotal() {
        return lastOutputTotal;
    }

    public AtomicLong getLastErrorTotal() {
        return lastErrorTotal;
    }

    public AtomicLong getLastFilterTotal() {
        return lastFilterTotal;
    }

    public AtomicLong getInputCount() {
        return inputCountAtomic;
    }

    public AtomicLong getFilterCount() {
        return filterCountAtomic;
    }

    public AtomicLong getErrorCount() {
        return errorCountAtomic;
    }

    public AtomicLong getOutputCount() {
        return outputCountAtomic;
    }


}
